package client.meetingview;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import miscellaneous.Storage;

/**
 * This class format the visual of a JTable
 * @author daniel
 */

public class TableRenderer extends DefaultTableCellRenderer {
	
	private JLabel label;
	
	public TableRenderer() {
		super();
	}
	
	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, 
			boolean isSelected, boolean hasFocus, int row, int column) {
		label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		
		if(value != null) {
			if(value.equals("Avtale")) {
				label.setBackground(Storage.colorAppointmentFill);
			} else if (value.equals("Møte")) {
				label.setBackground(Storage.colorMeetingFillAnswered);
			}
		}
				
		//Because of bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4197614
		//Do not set: setSelectionBackground(getBackground());
		//Do not set: setToolTipText("Klikk for mer informasjon om møtet");
		
		return label;
	}

}
